package xiangmu.schoolpaper.controller.system;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xiangmu.schoolpaper.pojo.VO.TeacherinfoVO;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.impl.system.TeacherinfoServiceImpl;

@Slf4j
@RestController
@RequestMapping("/system")
@Tag(name="教师信息接口")
public class TeacherinfoController {
    @Autowired
    public TeacherinfoServiceImpl teacherinfoServiceImpl;
    //添加教师信息
    @GetMapping("/add/teacher")
    @Operation(summary = "添加教师信息")
    public Result add(@RequestBody TeacherinfoVO teacherinfo){
        log.info( "添加教师信息{}",teacherinfo);

        teacherinfoServiceImpl.add(teacherinfo);
        return Result.success();
    }

    //修改教师的信息
    @GetMapping("/update/teacher")
    @Operation(summary = "更新教师信息")
    public Result update(@RequestBody TeacherinfoVO teacherinfo){
        log.info("更新教师信息{}",teacherinfo);
        teacherinfoServiceImpl.update(teacherinfo);
        return Result.success();
    }
    //删除教师信息
    @GetMapping("/delete/teacher")
    @Operation(summary = "删除教师信息")
    public Result disable(@RequestBody TeacherinfoVO ids){
        log.info("删除id为{}的教师信息",ids);
        teacherinfoServiceImpl.disabled(ids);
        return Result.success();
    }
    @PostMapping("/delete/teachers")
    public Result delete(Integer[] ids){
        log.info("批量删除id为{}的教师信息",ids);
        teacherinfoServiceImpl.delete(ids);
        return Result.success();
    }
}
